﻿<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <%@include file="../../common/include_list_head.jsp" %>
    <script type="text/javascript">
        var left_index = 0;
        var right_index = 0;
        var size = parseInt('<s:property value="listApp.size()"/>');

        $(document).ready(function () {

            //第一个二级菜单选中

            $("li[id='ulli_0']").addClass("current");


            if ($.browser.mozilla || ($.browser.msie && $.browser.version > 8)) {
                setTimeout("showButtonList()", 500);
            } else {
                showButtonList();
            }
            //只读模式
            var url = location.href;
            var readOnly = false;
            if (url.indexOf("readOnlyPage") != -1) {
                var readOnlyPage_value_index = url.indexOf("readOnlyPage") + "readOnlyPage=".length;
                readOnly = url.substr(readOnlyPage_value_index, 4) == 'true';
            }
            if (readOnly) {
                $("li a[href*='businessTabBut-list.action']").each(function (i) {
                    var href = $(this).attr("href");
                    $(this).attr("href", href + "&readOnlyPage=true");
                });
                $("div iframe[src*='businessTabBut-list.action']").each(function (i) {
                    var href = $(this).attr("src");
                    $(this).attr("src", href + "&readOnlyPage=true");
                });
            }
        });
        detailPageStyle();

        var menues_init = '<s:property value="menues"/>';

        //        function doSave(){
        //
        //            if( !checkInput("rolename","名称不能为空！") ){
        //                return false;
        //            }
        //
        //            return super_doSave();
        //
        //        }
        /**
         * 调整权限菜单按钮格式
         * @memberOf {TypeName}
         */
        function showButtonList() {
            var buttons_width = '';
            $("li[id^='ulli_']").each(function (i) {
                if (i != 0) buttons_width += ';';
                buttons_width += i + ":" + $("#ulli_" + i).width() + ":" + $(this).find("span").html();
            });

            var width_document = document.body.clientWidth;
            var ws = buttons_width.split(";");
            var wis = 0;
//        alert(width_document);
            //alert("ws:"+ws.length) ;
            for (var i = 0; i < ws.length; i++) {
//			wis +=	parseInt(ws[i].split(':')[1]);
                var fontNum = parseInt(( ws[i].split(':')[2] ).length);
                wis += fontNum * 20;
//            alert(wis);
                right_index = i;
                if (wis > width_document - 240) {
                    break;
                }
            }
            if (right_index < size) {
                for (var j = right_index + 1; j < size; j++) {
                    $("#ulli_" + j).hide();
                }
                $(".simpleTab_top").prepend("<li id='left_button' style='width:20px'><a onclick='javascript: trunleftorright(0)' target='frmrightChild' style='width:20px'>"
                        + "<span class='' style='width:16px;padding: 0 0 0 0;color:green'>《</span></a></li>");
                $(".simpleTab_top").append("<li id='right_button' style='width:20px'><a onclick='javascript: trunleftorright(1)' target='frmrightChild' style='width:20px'>"
                        + "<span class='' style='width:16px;padding: 0 0 0 0;color:green'>》</span></a></li>");
                $("#left_button span").addClass("icon_btn_left");
            }
            changeTurnButton();
        }
        function trunleftorright(obj) {
            if (obj == 0) {
                if (left_index != 0) {
                    left_index -= 1;
                    right_index -= 1;
                }
            } else {
                if (right_index != size - 1) {
                    left_index += 1;
                    right_index += 1;
                }
            }

            for (var i = 0; i < size; i++) {
                if (i < left_index || i > right_index) {
                    $("#ulli_" + i).hide();
                } else {
                    $("#ulli_" + i).show();
                }
            }
            var current_index = parseInt($("li[id^='ulli_'][class='current']").attr("id").substr(5));
            if (current_index < left_index || current_index > right_index) {
                $("li[id='ulli_" + current_index + "']").removeClass("current");
                $("li[id='ulli_" + left_index + "']").addClass("current");
                $("li[id='ulli_" + left_index + "'] a span").click();
            }
            changeTurnButton();
        }
        function changeTurnButton() {
            if (left_index != 0) {
                $("#left_button").show();
            } else {
                $("#left_button").hide();
            }
            if (right_index != size - 1) {
                $("#right_button").show();
            } else {
                $("#right_button").hide();
            }
        }
    </script>
</head>

<body>
<div id="scrollContent">
    <div class="box1" panelWidth="100%">
        <s:if test="#request.type=='user'">
        <div class="border_red" style="padding: 10px">“角色用户关联”适用于大量用户初始化后，批量给一群用户赋予某个角色。以及批量取消一群用户的特定角色。单个用户可在“全校用户管理”菜单调整。</div>
        </s:if>
        <s:hidden name="tsysRole.roleid"/>
        <s:hidden id="menues" name="menues"/>
        <s:hidden id="menuebuttons" name="menuebuttons"/>

        <table class="tableStyle" transMode="true" footer="normal">
            <tr>
                <td align="left" width="100%" nowrap="nowrap" colspan="5">
                    <div class="box1" panelWidth="600" align="left">
                        <div class="simpleTab" iframeMode="true">
                            <ul class="simpleTab_top">
                                <s:iterator value="listApp" status="stuts">
                                    <li id='ulli_<s:property value="%{#stuts.index}"/>'><a
                                            href="${basePath}/business/businessTabBut-list.action?appid=<s:property value='appid'/>&type=${type}"
                                            target="frmrightChild">
                                        <span><s:property value="appname"/> </span></a></li>
                                </s:iterator>
                            </ul>
                            <div class="simpleTab_con" >
                                <IFRAME scrolling="no" width="100%" frameBorder=0 id=frmrightChild
                                        name=frmrightChild onload="iframeHeight('frmrightChild')"
                                        src="${basePath}/business/businessTabBut-list.action?appid=<s:property value='appid'/>&type=${type}"
                                        allowTransparency="true"></IFRAME>
                            </div>
                        </div>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>
</body>
</html>
